home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / aplibs91.zip / APLIB.DOC < prev    next >
Text File  |  1991-05-03  |  42KB  |  797 lines

  1.  
  2.                +---------------------------------------------+
  3.                |                                             |
  4.                |                                             |
  5.                |      THE NEW HB ALL-PURPOSE LIBRARY         |
  6.                |                                             |
  7.                |        FOR POWER-BASIC PROGRAMMERS          |
  8.                |                                             |
  9.                |       INTRODUCTION AND DOCUMENTATION        |
  10.                |                                             |
  11.                |                                             |
  12.                +---------------------------------------------+
  13.  
  14.  
  15.                     Version 2.5    //    SPRING 1991
  16.  
  17.                    compatible with: POWER BASIC v. 2.1
  18.  
  19.                            ==================
  20.  
  21.    Here it comes again !! An update of my little all purpose library of
  22.    programming tools. For those who never heard of this humble work, it
  23.    contains PB routines to allow you to write complete pulldown menu
  24.    interfaces, rodent-aware, just by copying a demo program; fancy entry
  25.    routines for string or numeric data, phone #s, dates etc (never use INPUT
  26.    again!), date arithmetic, get file dirs & diskspace, open a data-entry
  27.    window, dialog box, let users customize colors, push & pop screens, & much
  28.    more! All in PB units. Free for casual use; if you use it to make money I
  29.    do request that you send me a little. Just whatever you think it's worth.
  30.    It has happened -- and I do much appreciate it, as an acknowledgement of my
  31.    MANY hours' work as well as extra dinero.
  32.  
  33.    I am a householder and non-computer professional; I do programming as a
  34.    more-or-less useful avocation. This custom routines library was written by
  35.    stages over a few years time, first for Turbo Basic (there are even echos
  36.    of GeeWhiz Basic in here), and mostly for my own use in database programs
  37.    and my custom dos shell. Also I include my do-nothing demo program which
  38.    I use to develop and demonstrate the functions in the library; this file,
  39.    HBDEMO.BAS, also contains detailed how-to instructions (embedded as
  40.    clever remarks) to help you guys (M or F) use it in your own programming
  41.    projects.
  42.  
  43.           ==========================================================
  44.  *--->                 TO CREATE AND RUN THE DEMO --
  45.               Having installed POWER BASIC 2.1 on your HD, simply
  46.              put these files in a clean directory & enter MAKEDEMO
  47.           ==========================================================
  48.  *--->        TO PRINT DOC: do the above, then from the main menu
  49.                 select first [ F ]  then [ P ]  (about 10 pages)
  50.           ==========================================================
  51.  
  52.    FEATURES:
  53.     ------
  54.  
  55.       MAIN MENUS ACROSS TOP OF SCREEN AND PULLDOWN SUBMENUS -- WITH
  56.         STANDARD KEYBOARD AND MOUSE CONTROL INTERFACE.
  57.            \\ NEW: Buttons to click on at the bottom of the screen w/
  58.                    Alt-key synonyms.
  59.            \\ NOW: Time-out feature works ! (In HBDEMO it blanks the screen)
  60.                    Improved mouse interface. Selectable click/release mode.
  61.  
  62.       POP UP AND VANISH MENUS AND DIALOG BOXES, ANYWHERE ON THE SCREEN
  63.  
  64.       INPUT ROUTINES FOR TEXT FIELDS, NUMBERS, DATES ETC. W/ FULL EDITING --
  65.  
  66.       SPECIAL DATE ENTRY ROUTINE THAT "SCROLLS" THE DATE FORWARD OR BACK
  67.       (starting for example with the present date) USING ARROW KEYS 
  68.  
  69.       FULL DATE ARITHMETIC BACK TO 1900. SPECIAL AGE FUNCTION. 
  70.  
  71.       POP-UP DATA ENTRY WINDOWS  -- CURSOR OR TAB BACK AND FORTH FROM
  72.         FIELD TO FIELD
  73.       
  74.       ROUTINES TO GET DISK, DIRECTORY AND SYSTEM INFO DIRECTLY FROM DOS
  75.          \\ NEW: Routine to read directories. Multipage menus to select
  76.                  a directory and to select a filename.
  77.  
  78.       SMART PRINTER CALL WITH AUTOMATIC PAGINATION, HEADERS, FOOTERS
  79.          \\ NOW: works.
  80.  
  81.       AUTOMATIC DETECTION OF COLOR / MONO DISPLAY and uniform color handling.
  82.  
  83.       SEPARATELY COMPILED POWER-BASIC UNITS. ALL IN BASIC FOR RELIABILITY
  84.         AND EASY MAINTENANCE, WITH EXTENSIVE ERROR-PROOFING
  85.          \\ NEW: Supports editing .BAS files with QEdit. If there's an error,
  86.                  either on compile or at run-time, you are automatically
  87.                  returned to QEdit at the line where the problem occurred.
  88.                  
  89. ________________________________________________________________________________
  90.  
  91.                  THE FILES AND WHAT THE HECK TO DO WITH THEM
  92.                        ============================
  93.  
  94.      APLIB    DOC          The file you're reading now; part of the doc.
  95.  
  96.      HBDEMO   BAS          This is the demo. Compile it to an EXE file using
  97.                            Power Basic and you'll see about all the tricks 
  98.                            these units and utilities can do. Also contains 
  99.                            more documentation for the various procedures and
  100.                            functions (as comments).
  101.  
  102.      MAKEDEMO BAT          automatically creates the PBU files, INC files, 
  103.                            PUBLIC Variables list and demo on your machine.
  104.  
  105.      ENTERDEM SW           { The SW files are screen design files for Static
  106.      FILEDATA SW           {   Windows (display text & data but no user entry).
  107.      OPENDEMO SW           {   The INC files are the result of processing them
  108.      COLORSET SW           {   through the SWW.EXE utility (see below)
  109.      
  110.  
  111.                            { PW files are design files for PopWindows -- data
  112.      CKWINDOW PW           {   entry windows. PWW makes them into INC files.
  113.                            {   This demo simulates entry into a fake checkbook
  114.                            {   database program. NOTE: INSTRUCTIONS FOR CREATING
  115.                            {   POPWINDOWS ARE INCLUDED IN THIS PW FILE.
  116.                            
  117.  
  118.      APLIB-H  BAS          Header (must $INCLUDE in all progs calling AP Lib)
  119.      APLIB-F  BAS          Footer (must $INCLUDE in all progs calling AP Lib)
  120.  
  121.      BOXES-U  BAS          |
  122.      FENTRY-U BAS          |
  123.      FIGDAT-U BAS          |    The units comprising the library. 
  124.      INIT-U   BAS          |
  125.      MENUS-U  BAS          |
  126.      MISC-U   BAS          |
  127.      NEW-U    BAS          |
  128.  
  129.      PUBVARS  BAS          |   THREE UTILITIES: PWW and SWW are code generators
  130.      PWW      BAS          |   that create *.INC files for opening the two types
  131.      SWW      BAS          |   of data windows -- one for entry, one just to
  132.      COLORSET BAS          |   display data (see above).  Of course the idea
  133.                            |   is that you can edit the .PW or .SW files all
  134.                            |   you want to, then reprocess them to get an
  135.                            |   updated display. PUBVARS automatically creates
  136.                            |   lists of PUBLIC variables to match the EXTERNAL
  137.                            |   statements in all the units linked to a
  138.                            |   program.
  139.                            |
  140.                            |   COLORSET automates the process of using command 
  141.                            |   line switches to reset the colors of the Demo
  142.                            |   (or any PB program that uses the SetColors 
  143.                            |   routine). Start it and follow directions! 
  144.  
  145.      ERFIND   BAS          |   These files comprise the PB - QEdit interface
  146.      PQ       BAT          |   described above. PBD is to edit and compile
  147.      PBD      BAT          |   HBDEMO.BAS and its accompanying files (press
  148.      2ERRORS  BAS          |   Alt-N in QEdit to switch)
  149.  
  150.  
  151.      If you find an PICKADIR.LST among the files you receive, you might want
  152.      to delete it. It probably contains the directory structure of the
  153.      computer of the guy who gave you the files !
  154.  
  155. ________________________________________________________________________________
  156.                     
  157.                       NEW STUFF ADDED @ LAST UPDATE
  158.                        ---------------------------
  159.  
  160.      Version 2.00002 was released in November '90, and worked with either PB
  161.      2.0 or 2.1. I incorporated some suggested improvements and 3 fixes into
  162.      FENTRY-U. Added SUB FASTPHONE(), much better than ENTERPHONE() and based
  163.      on a user suggestion; fixed ROTADATE() so you can choose the cursor key
  164.      system (incr/decr date) or just type in a 4 or 6-digit date without
  165.      pressing the spacebar first (thanks, Al); bulletproofing of QBox() and
  166.      BOXMESSAGE() and made a new demo routine to test them; made InsertStatus
  167.      for the entry routines a Global var. so it stays set from field to field
  168.      and made minor improvements in PWW & SWW which don't affect input or
  169.      output; wrote MAKEDEMO.BAT.
  170.          
  171.  
  172.   +---------------------------------------------------------------------------+
  173.   |                NEW STUFF ADDED  --  WINTER - SPRING 1991                  |
  174.   +---------------------------------------------------------------------------+
  175.   |                                                                           |
  176.   |      ERFIND.BAS was written because most of my work in PowerBASIC         |
  177.   |      uses the command-line compiler and the shareware editor QEDIT.       |
  178.   |      It duplicates the handiest features of the PB environment: when      |
  179.   |      an error occurs in compilation OR at runtime, I'm automatically      |
  180.   |      taken back to the source file at the line where the error occurs!    |
  181.   |                                                                           |
  182.   |      The operation is as follows:                                         |
  183.   |                                                                           |
  184.   |       (1) If a runtime error occurs, the error handler writes up a        |
  185.   |           little batch file; then it stuffs its name into the keyboard    |
  186.   |           buffer and exits. This causes the .BAT file to run immediately  |
  187.   |           after the .EXE terminates.                                      |
  188.   |                                                                           |
  189.   |       (2) This batch file runs PBC with the /RE parameter. PBC writes     |
  190.   |           the line number of the error onto the screen. Then the          |
  191.   |           batch file runs ERFIND, which picks the line number off the     |
  192.   |           screen.                                                         |
  193.   |                                                                           |
  194.   |       (3) ERFIND then writes another batch file to disk (preferably a     |
  195.   |           RAM-disk) then exits after stuffing ITS name in the keyboard    |
  196.   |           buffer. The batch file then starts QEdit passing the line       |
  197.   |           number to it behind a /G command line parameter ... and         |
  198.   |           after you finish editing your goof-ups, proceeds with another   |
  199.   |           compile / execute cycle.                                        |
  200.   |                                                                           |
  201.   |                           RUBE GOLDBERG LIVES !!                          |
  202.   |                                                                           |
  203.   |       (4) In the case of a compile-time error, the process starts         |
  204.   |           in the middle of a simple batch file (PQ.BAT) which, if it      |
  205.   |           detects that PBC has set ERRORLEVEL, starts ERFIND which        |
  206.   |           again picks the line # where the error occurred off the         |
  207.   |           screen. GOTO "(3)".                                             |
  208.   |                                                                           |
  209.   |       Another new doodad is the procedure to find and list all the        |
  210.   |       subdirectories on your disk, and make them into a menu --           |
  211.   |       PICKADIR$. It takes several seconds at least, so the list is        |
  212.   |       saved for re-use as a file (HBDEMO.DRL).                            |
  213.   |                P.S. -- ran much faster after I defragmented my drive !!   |
  214.   |                                                                           |
  215.   |       To go along with that there is PICKAFILE$.                          |
  216.   |                                                                           |
  217.   |       On-screen push-buttons have been added. These as well as the        |
  218.   |       above are in a new unit, cleverly titled NEW-U.BAS.                 |
  219.   |                                                                           |
  220.   |       New improved mouse interface! Customize response in SUPERMENU       |
  221.   |       (1st release, 1st click, 2nd release or whatever you & your         |
  222.   |       end-users want).                                                    |
  223.   |                                                                           |
  224.   |       Last-minute bugfix: lack of a leading zero was throwing             |
  225.   |       FIGDATE off.                                                        |
  226.   |                                                                           |
  227.   |       Also notable: the printer control procedure PRINTLINE has been      |
  228.   |       improved and is demonstrated in the demo (prints this file out).    |
  229.   |                                                                           |
  230.   |       Last but Not Least -- REWRITTEN DOCUMENTATION.                      |
  231.   |                                                                           |
  232.   |       NOTE: If you still use PB version 2.0 it will take some tinkering   |
  233.   |       to use this version of APLIB.                                       |
  234.   |                                                                           |
  235.   +---------------------------------------------------------------------------+
  236.  
  237.    There is still an initialization procedure (in INIT-U.BAS) which sets
  238.    itself up for color or mono monitor and several types of printer (you can 
  239.    see what kinds of printers I've used -- there are drivers for them!). Works
  240.    on Mono, CGA, EGA & VGA in text mode. Thanks to the PB functions PEEK$ and
  241.    POKE$, screens are quickly saved to regular memory space. See SCREENPUSH
  242.    and SCREENPOP.
  243.  
  244.   A NOTE ABOUT MY STYLE:  You may be horrified at my use of GOTO and GOSUB in
  245.   =====================   these files. Well, I don't like puzzles, I don't
  246.          care for C, and I see NO reason to use contrived outer loops and
  247.          unnecessary flag variables to avoid a simple, clear and self-evident 
  248.          jump (e.g. GOTO FileSubMenu). And why, I say, incur all the overhead 
  249.          of a SUB procedure, with a ton of SHARED variables to pass, and no 
  250.          local variables at all ... when a GOSUB / RETURN stucture is faster 
  251.          (maybe measurably, maybe no) and does the job perfectly for me and 
  252.          you. Anyway, that's how I do it.
  253.           
  254.   A NOTE ABOUT THE DOCUMENTATION: Really much of the good info about the
  255.   ==============================  use of the functions and procedures in
  256.          APLIB are to be found in the comments in the demo file, HBDEMO.BAS.
  257.          However there are some notes about each in this DOC file also. Most
  258.          of the facts agree between the two.
  259.  
  260.   A NOTE ABOUT LIMITATIONS AND OTHER FAULTS:  Works only in 25-line text mode.
  261.   =========================================   Not optimized for code size,
  262.                                               obviously -- but feel free to
  263.          dig in and "hack" out unused code and trim it all you can if you like.
  264.  
  265.  
  266. ' ============================================================================
  267.                     |                                       |
  268.                     | GETTING STARTED WRITING A POWER-BASIC |
  269.                     |          PROGRAM USING APLIB          |
  270.                     =========================================
  271.  
  272.        (myself, I usually start with a copy of HBDEMO.BAS and replace all
  273.                          the old works with new works)
  274.  
  275.    1. $INCLUDE the file APLIB-H.BAS at the top of your file. It dimensions
  276.       some arrays, sets some named constants and variables etc. Follow that
  277.       with the seven $LINK statements.
  278.  
  279.    2. Now you need the PUBLIC statements. Just include a line like: $INCLUDE
  280.       "FOO.PV" --   and then type PUBVARS FOO from the command line to automate
  281.       this chore.
  282.  
  283.    3. CALL Initialize (), then GOSUB SetColors. $INCLUDE the file APLIB-F.BAS
  284.       at the end of your file. It contains the error handler and some small
  285.       subroutines.
  286.  
  287.    4. If you want the full-screen menu system with pulldowns etc. the next
  288.       major APLIB call will be to TOPMENU, followed by SUPERMENU's. If you
  289.       want the main menu to time out, set TimeOut to however many seconds.
  290.       If you want push-buttons, set UseButtons to %True and define the
  291.       button data the way the demo does.
  292.  
  293.                     GOOD LUCK. LET ME KNOW HOW IT GOES.
  294.  
  295. ' ============================================================================
  296.   
  297.  
  298.              QUICK REFERENCE FOR HB'S ALL-PURPOSE LIBRARY:
  299.              ============================================
  300.  
  301.       What's in APLIB-H.BAS  ??????????
  302.        ------------------------------
  303.  This is a header file which MUST be $INCLUDE'd. It doesn't contain any
  304.  executable code that I can think of -- except DIM DYNAMIC statements.
  305.  Otherwise what it has is: the DEFINT statement; %False, %True, Register
  306.  Names, Colors and other Named Constants, plus DIM statements ... etc.
  307.  Generally everything needed to set up for use of this library.
  308.  
  309.  %False =  0
  310.  %True  =  NOT %False '                       basic truths of the universe ...
  311.  %Yes = %True
  312.  %No = %False
  313.  
  314.  %Background = 16
  315.  %Center = 0
  316.  
  317.   %Blk = 0:     %Blu = 1:    %Grn = 2:    %Cyn = 3:    %Red = 4:     %Vlt = 5
  318.   %Brn = 6:     %Gry = 7:    %DGry = 8:   %LBlu = 9:   %LGrn = 10:   %LCyn = 11
  319.   %LRed = 12:   %Pnk = 13:   %Ylo = 14:   %Wht = 15:   %Flash = 256
  320.  
  321. ________________________________________________________________________________
  322.  
  323.         What's in APLIB-F.BAS ?????????
  324.          -----------------------------
  325.  (This "footer" file, like APLIB-H, is necessary. It contains executable
  326.  subroutines, so $INCLUDE it at the end (or at least somewhere it won't get
  327.  "fallen into")).
  328.  
  329. Oops:                   (error handler with new "self-debugging" features)
  330. SetBeeps:
  331. MZap:                   (clears away a pulldown menu in a mere trice)
  332. ClickOrStrike:          (waits for a key- or mouse-stroke)
  333. SetColors:
  334. WipeLn:
  335. SUB Marker (Msg$)       (for debugging: displays message & waits for keystroke)
  336. ________________________________________________________________________________
  337.  
  338.       What's in INIT-U.BAS   ???????????
  339.        -------------------------------
  340. SUB Initialize (PrinterType)
  341. ________________________________________________________________________________
  342.  
  343.  
  344.       What's in FENTRY-U.BAS  ??????????
  345.        --------------------------------
  346. SUB ENTERSTRING (Wkg$,FLength,Msg$)             |  These are the Formatted
  347. SUB ENTERNUMBER  (Wkg#, Masq$, Msg$)            |  Entry routines
  348. SUB ENTERDATE  (A$, Msg$)                       |
  349. SUB RotaDate  (D$,Msg$)                         |
  350. SUB ENTERTIME  (A$, Msg$)                       |
  351. SUB ENTERSSN  (A$, Msg$)                        |
  352. SUB ENTERPHONE  (A$, Msg$)                      |
  353. SUB FASTPHONE (A$, Msg$)                        |
  354.  
  355. SUB PressAKey                  Displays a little box that says Press A Key
  356.                                If you have mouse, says you may also Click
  357.  
  358. FUNCTION GETYESORNO            Prints "y/n" and waits til you answer with
  359.                                an appropriate key or mousebutton (Left = Yes)
  360.                                (4-91: now accepts down arrow as a "No")
  361.  
  362.                5-91: graphic Mouse Prompt comes up the on the first two calls,
  363.                if mouse in use (i.e. if NeedDCon = %True). You may or may not
  364.                care for it. If not it's easy to disable it.
  365.  
  366. SUB ENTERYESNO  (Yes)          Prints a field with a Y or N in it; press
  367.                                Y or N or [Enter]. Used in data entry windows.
  368. ________________________________________________________________________________
  369.  
  370.  
  371.       What's in BOXES-U.BAS ???????????
  372.        -------------------------------
  373. SUB BOXMESSAGE(CornerLin, CornerCol, Margin)
  374. SUB BOXMESSAGE2 (CornerLin, CornerCol, Margin, I$(1), Items%, Maxx)
  375.                         (prints a box, with lines of text you specify in it.)
  376.  
  377. SUB POPWINDOW                  prints a window with entry fields in it and
  378. SUB PWSetUp (Fld$, Z)          readies it for data entry. The window is
  379.                                designed by you as a .PW file, preprocessed
  380.                                by PWW into an .INC file and included in the
  381.                                source file. A RESTORE statement must be
  382.                                executed first. Fld$ is the string label used
  383.                                in the .PW file to designate each specific
  384.                                field.
  385.  
  386. SUB QBOX (L, C, Lines%, Message$, AnsFldLength)         (one-field dialog box)
  387. ________________________________________________________________________________
  388.  
  389.       What's in MENUS-U.BAS ????????????
  390.        -------------------------------
  391. SUB TOPMENU (Lines%, Choice, TLine$)                           +--------------+
  392.                        Top of screen menu; select with letter  | Now with     |
  393.                        key, cursor and CR, or click and        |  QUICKCLIK   |
  394.                        pull-down with your Furry Friend.       |    Buttons !!|
  395.                                                                +--------------+
  396. SUB POPMENU (TopKey$,MenuRight,MenuDown,Choice,MLine$,MCode$)
  397.                                  (retained only for compatibility with old code)
  398.  
  399. SUB SUPERMENU (MenuData$$ (), MenuRight, MenuDown, Choice, Title$, Ky%)
  400.                          Regular moving-bar menu with mouse or keybd selection,
  401.                          optional pulldown style or multipage styles, optional
  402.                          help lines that appear in line 25. Supports multipage
  403.                          megamenus.
  404. ________________________________________________________________________________
  405.  
  406.  
  407.       What's in FIGDAT-U.BAS ?????????????
  408.       -----------------------------------
  409.  FUNCTION FigDate&(A$)                 convert a date to a "Julioid" long-int
  410.  FUNCTION WriteDate$ (W&)              convert the other way
  411.  FUNCTION WkDay$(W&)                   what day of the week is a given date
  412.  FUNCTION YearsSince (D0$)             how old is a client born on D0$
  413.  
  414.  FUNCTION FlipDate$ (WrittenDate$)     rearrange date for sorting
  415.                                              or indexing (e.g. 900829)
  416.  FUNCTION UnflipDate$ (FlippedDate$)   unrearrange date into readable form
  417.                                              (e.g. 08-29-90)
  418. ________________________________________________________________________________
  419.  
  420.       What's in MISC-U.BAS  ???????????
  421.       --------------------------------
  422. SUB SCREENPUSH                        |
  423. SUB SCREENPOP                         |  screen save & restore
  424. SUB RestoreDOSScreen                  |
  425.  
  426. SUB PRINTLINE (L$)           (fancy printer control -- keep track of pages etc.
  427.                               NOW: intelligent Print-to-Disk support also!
  428.                                Pass "START" message to PRINTLINE at the outset,
  429.                                 an "END" message to finish off.)
  430.  
  431. FUNCTION GetAttr                           (what is the color at the cursor ??)
  432. FUNCTION ReadParamFor (A$)         this reads parameters from the command tail
  433. SUB ClearLine                             clear a line on screen w/o scrolling
  434.                       (it seems some BIOS's scroll if you write to 25,80 at all)
  435.  
  436. FUNCTION IsRodent               ' finds if you have a rodent and also resets it
  437. SUB Mouse(MV1, MV2, MV3, MV4)
  438. FUNCTION MouseClicked
  439.  
  440. FUNCTION GetCurrentDrive$
  441. FUNCTION GetCurrentDir$
  442. FUNCTION GetFreeSpace! (Drv$)
  443.  
  444. FUNCTION EXIST (File$)                 needed for PB 2.0 only (use DIR$ in 2.1)
  445.  
  446. SUB DirFirst (F$, FileSize&, DateCode&, TimeCode&)          |
  447. SUB DirNext (F$, FileSize&, DateCode&, TimeCode&)           | slower than DIR$
  448. FUNCTION DecodeDate$ (DateCode&)                            | but able to return
  449. FUNCTION DecodeTime$ (TimeCode&)                            | date, time, size.
  450.  
  451. FUNCTION FQFileSpec$ (A$)        '            returns path + filename of a file
  452. FUNCTION Cen$ (A$)        '                pads a string for centering onscreen
  453. FUNCTION MKU$ (Unsigned&)        '         represents a 2-byte unsigned integer.
  454. FUNCTION CVU& (TwoByteNum$) '           Stores it (as a 16-bit int, of course)
  455.  
  456. SUB BufferStuffer (M$)        '            stuff the DOS keyboard buffer w/ a
  457. '                                          command to be executed after your
  458. '                                          PB program ends !!
  459. ________________________________________________________________________________
  460.  
  461.       What's in NEW-U.BAS  ???????????
  462.       -------------------------------
  463. SUB ButtonButton PUBLIC SHARED            Creates buttons onscreen for the
  464.                                             user to click on ...
  465. FUNCTION ButtonIsClick (L, C) PUBLIC      If the user did click on a button
  466.                                             returns button number (1..5); else
  467.                                             returns 0
  468.  
  469. SUB MegaMenu (Foo$(), Choices%, Choice, ItemChosen$)   Multipage menu from any
  470.                                                        size array of choices
  471.  
  472. FUNCTION PICKADIR$ PUBLIC                  Menus of subdirectories and files
  473. FUNCTION PICKAFILE$ (D2Use$) PUBLIC          respectively; will be multi-paged
  474.                                                if > 23 of either are found on
  475.                                                  the disk.
  476.  
  477. ===============================================================================
  478.  
  479.             ++++++++++++++++++++++++++++++++++++++++++++++++++
  480.             +                 __  ____    ___  ____          +
  481.             +        |    |  /    |  |   /     |_            +
  482.             +        |    |  \_   |__|  |   +  |     *       +
  483.             +         \__/   __|  |  |   \__|  |___  *       +
  484.             +                                                +
  485.             ++++++++++++++++++++++++++++++++++++++++++++++++++
  486.  
  487.  
  488.                           USING BOXMESSAGE
  489.                           ^^^^^^^^^^^^^
  490.  The SYNTAX:     CALL BOXMESSAGE (CornerLin, CornerCol, Margin)
  491.  
  492.  The INPUT:      DATA statements, each containing one line of text to display,
  493.                  followed by "DATA END". (Don't forget to RESTORE to a label
  494.                  above the DATA for your box).
  495.  
  496.  The COLORS:     BoxColor
  497.  
  498.  The OPTIONS:    Positions the left upper corner of the box at CornerLin,
  499.                  CornerCol -- or for centering on either axis use %Center
  500.                  for one or both parameters. Errors are trapped so the box
  501.                  should stay onscreen. Use a margin (1 or more) if you like.
  502.                  Set FlashBox = %True to flash just the frame.
  503.  
  504.  The OUTPUT:     Just the box with text in it.
  505.  
  506.  The RETURN:     No return variables.
  507. ________________________________________________________________________________
  508.  
  509.                     USING ENTERSTRING
  510.                       ^^^^^^^^^^^^^
  511.                                 ( ... and its children, ENTER* )
  512.  
  513.  The SYNTAX:     CALL ENTERSTRING (Wkg$, FLength, Msg$)
  514.                  CALL ENTERNUMBER  (Wkg#, Masq$, Msg$)
  515.                                                               ... etc.
  516.  
  517.  The INPUT:      Wkg$ is the data string in the field at the outset (may
  518.                  be empty). FLength is number of chrs that it can hold.
  519.                  Masq$ is a number formatting string for PRINT-USING use.
  520.  
  521.  The COLORS:     FldColor
  522.  
  523.  The OPTIONS:    Msg$ may be "" or may contain one or more strings that
  524.                    will control ENTERSTRING'S behavior.
  525.                     Msg$ = "Cap" for all uppercase
  526.                     Msg$ = "Auto" for automatic entry when field is filled
  527.                     Msg$ = "UpOut" if UpArrow or Shf-Tab keys are to be able
  528.                             to terminate entry.
  529.                     Msg$ = "BackOut" if LeftArrow & Backspace keys are to be
  530.                             able to terminate entry.
  531.                     Msg$ = "-" if minus sign (negative numbers) are to be
  532.                             accepted.
  533.  
  534.                   InsertStatus is a GLOBAL var -- that way it stays set
  535.                   where you want it (Insert or Overwrite) between fields.
  536.  
  537.  The OUTPUT:     a field FLength characters long, beginning at the present
  538.                  cursor location, for the user to enter stuff into. It
  539.                  contains a cursor (big if InsertStatus is %True, else
  540.                  small) and also the contents of Wkg$ if any. It reponds to
  541.                  all the customary editing commands including ^arrow-key,
  542.                  ^Y, ^T and ^U. At any time during string entry the operator
  543.                  can press [CR] or DOWN-ARROW to enter; or [F1] or [F2].
  544.                  Optional beep for errors.
  545.  
  546.   The RETURN:    On exiting sub, Msg$ may be reset as "Left", "Auto", "Up",
  547.                  "ShfTab", "Down", "Tab", "ESC", "CR", "F2" or "HELP!".
  548.                  Wkg$ is now whatever the user entered.
  549.  
  550. ________________________________________________________________________________
  551.  
  552.                           USING POPWINDOW
  553.                            ^^^^^^^^^^^^^
  554.  The SYNTAX:     CALL POPWINDOW
  555.  
  556.  The INPUT:      The DATA statements in an $INCLUDE file, generated
  557.                  automatically by PWW.EXE from a window design template file
  558.                  (*.PW). NOTE: Just don't forget to RESTORE to a label above
  559.                  the $INCLUDE metastatement for the PopWindow.
  560.  
  561.   The COLORS:    WinColor and FldColor
  562.  
  563.   The OPTIONS:   None
  564.  
  565.   The OUTPUT:    A box resembling the template you made and processed, which
  566.                  contains text lines and blank fields; and an array in memory
  567.                  which allows PWSetUp() to do its thing.
  568.  
  569.   The RETURN:    None
  570. ________________________________________________________________________________
  571.  
  572.                         USING PWSetUp
  573.                         ^^^^^^^^^^^^^
  574.  The SYNTAX:    CALL PWSetUp (FieldName$, Tbl%)
  575.  
  576.  The INPUT:     FieldName$ identifies which of the fields in your PopWindow
  577.                 you are about to use. It must be the same name used to
  578.                 identify the field in the .PW file that created the PopWindow
  579.                 now open.
  580.  
  581.  The OUTPUT:   The cursor is set to the location of the named field by
  582.                means of a LOCATE statement.
  583.  
  584.  The RETURN:   Tbl% is the array subscript that pertains to the field named.
  585.                The mask string to go with the variable is FieldMask$ (Tbl%).
  586.  
  587.  
  588. ________________________________________________________________________________
  589.  
  590.                         USING TOPMENU
  591.                         ^^^^^^^^^^^^^
  592.  The SYNTAX:     CALL TOPMENU (Lines%, Choice, TLine$)
  593.  
  594.  The INPUT:      DATA statements, each containing one text label to display
  595.                  as a menu choice, followed by "DATA END". They must have
  596.                  different first letters, as the hotkey is always the
  597.                  initial: you press "F" for FILES etc. (Don't forget to
  598.                  RESTORE to a label above the DATA for your main menu).
  599.  
  600.                  To create buttons on-screen, you need to supply data for them
  601.                  to display and respond to also.
  602.  
  603.                    TopOfButtons = 19
  604.  
  605.                    ButtonMsg$ (1,1) = "  Open"
  606.                    ButtonMsg$ (1,2) = "  QEDIT"
  607.                    ButtonMsg$ (1,3) = "  Alt-A"
  608.                    Key2Alt (1) = 30               (button will respond to Alt-A,
  609.                                                       i.e. CHR$ (0) + CHR$ (30))
  610.                    Buttons% = 4                    (how many buttons? (1..5))
  611.                    UsingButtons = %True
  612.  
  613.  
  614.  The COLORS:     MenuColor, BarColor, ScrColor
  615.  
  616.  The OPTIONS:    Lines% is always 3 -- I've never tried a 2- or 1-line TOPMENU.
  617.                  If Escapable = %True, the escape key may be pressed as a
  618.                  response to the menu. TimeOut is a figure in seconds
  619.                  denoting how long TOPBAR will wait for you to make a choice
  620.                  (0 = forever). UsingButtons controls button painting and
  621.                  checking (ON if %True).
  622.  
  623.  The OUTPUT:     A menu bar across the top of the screen with several choices
  624.                  the user can select from in the usual ways -- mouse or key.
  625.  
  626.  The RETURN:     Choice will be the selection number. TimeOut (a PUBLIC
  627.                  variable) will be -1 (%True) if the menu did time out without
  628.                  user input -- else it's always reset to 0. TLine$ = "HELP!"
  629.                  if F1 was pressed, "ESC" if Escape, else the name of the
  630.                  choice chosen.
  631.  
  632. ________________________________________________________________________________
  633.  
  634.                         USING SUPERMENU
  635.                          ^^^^^^^^^^^^^
  636.  The SYNTAX:     CALL SUPERMENU (MenuData$(), MenuRight, MenuDown,_
  637.                                                Choice, Title$, KeyPressed%)
  638.  
  639.  The INPUT:
  640.                   
  641.                  Each choice on your menu is represented by one string
  642.                  element in the MenuData$ array. It looks like:
  643.  
  644.                             MenuData$(1) = "L LOAD"
  645.                                   -- or --
  646.                             MenuData$(1) = "  LOAD"
  647.  
  648.                  The description of each choice -- for example, "LOAD", will
  649.                  start with the third character of this string. If you are
  650.                  specifying the hot-key for each choice, put it into the
  651.                  first character. To let the software number or letter the
  652.                  items in order for you, MenuData$(1) should have two leading
  653.                  spaces. (If there are <10 items, numbers are used rather
  654.                  than letters.) After the last menu item, you must set the
  655.                  next array element as "END".
  656.  
  657.                  PASSING HELP LINES TO MENU: Set MenuHelpLine$() to contain
  658.                  lines (up to 80 chr long) These will appear at screen
  659.                  bottom whenever the corresponding menu choice is
  660.                  highlighted.
  661.  
  662.  The OPTIONS:    POSITION OF MENU ONSCREEN: MenuRight moves it right or left
  663.                  0 is center. MenuDown is 0 for top, up to 22 for bottom.
  664.                  Errors will be trapped. Vertical centering is gotten by
  665.                  setting MenuDown = 25. Usually set Choice = 1. Title$ is
  666.                  title of menu.
  667.  
  668.                  Pulldown is a global flag. If true it will behave like a
  669.                  pulldown should, and if you drag or cursor the selection
  670.                  bar through the top of the menu frame, SUPERMENU exits
  671.                  returning the same values as if Escape had been pressed.
  672.                  PgUp key will only function if the global variable
  673.                  UsePgUp = %Yes, and similarly for UsePgUp, UseRArrow,
  674.                  UseLArrow. If there is another page, cursoring or mousing
  675.                  past the bottom of the displayed page will simulate
  676.                  pressing PgDn; likewise pulling the menu bar above the top
  677.                  choice will simulate PgUp. All these globals are reset to
  678.                  %False after exit, but UseF1 isn't.
  679.  
  680.  The COLORS:     MenuColor, BarColor
  681.  
  682.  The RETURN:     Choice will hold the choice #. Title$ reset to "".
  683.                  KeyPressed% will encode the key used to exit the menu
  684.                  procedure -- %CR, %Esc, %PgUp, %PgDn, %RArrow, %LArrow,
  685.                  %F1, %F2. If left mouse button was used, it simulates the
  686.                  CR key, i.e. %CR -- or if Right mouse button = %Esc)
  687. ________________________________________________________________________________
  688.  
  689.                  USING QBox ()
  690.                  ^^^^^^^^^^^^^
  691.  The SYNTAX:  QBOX (L, C, Lines%, Message$, AnsFldLength)
  692.  
  693.  The INPUT:   Message$ is the one line text string to appear in the box.
  694.               AnsFldLength is zero (message only) or the amount of space to
  695.               leave for an entry field for user entry. (A dialog box will
  696.               consist of a QBox followed immediately by an entry routine
  697.               such as ENTERSTRING, ENTERNUMBER, ENTERYESNO or GETYESORNO.
  698.               For the latter, leave a space of 8 for the " (y/n) " that will
  699.               be printed.)
  700.  
  701.  The OPTIONS: L and C position the box just the same as in BOXMESSAGE. Lines%
  702.               is 1 or 3 and determines the type of box (see below).
  703.               Set FlashBox = %True to flash just the frame -- for added
  704.               noticeability on a cluttery screen (especially useful on
  705.               mono displays.)
  706.  
  707.  The COLORS:  BoxColor
  708.  
  709.  The OUTPUT:  The boxes look like this:
  710.  
  711.                                +-----------------------------+
  712.               One Line Qbox:   | Your Choice: ______________ |
  713.                                +-----------------------------+
  714.  
  715.                                  +--------------+
  716.               Three Line QBox:   | Your Choice: |
  717.                                  |              |
  718.                                  | ____________ |
  719.                                  +--------------+
  720.  
  721.               After QBox exits, the cursor (print position) is set at the
  722.               beginning of the answer field you set up, ready for the entry
  723.               routine to follow.
  724.  
  725.  The RETURN:  No return variables ("void", if you will)
  726. ________________________________________________________________________________
  727.  
  728.              USING Initialize ()
  729.                ^^^^^^^^^^^^^
  730.  The SYNTAX:   Initialize (PrinterType)
  731.  
  732.  The INPUT:    %Star10X, %StarNX1000, or %LQ2500 (these printer control code
  733.                    sets exist so far. You may need to modify them so as to
  734.                    write your own.)
  735.  
  736.  The OUTPUT:   A cleared screen with COLOR set at %Gry, %Blk (7, 0)
  737.  
  738.  The RETURN:   Public/global variables:
  739.  
  740.                  NeedDCon is %True if a rodent is found
  741.  
  742.                  ColorDisplay is %True if the low-memory PEEK shows color
  743.                    (checked by a write-peek test).
  744.  
  745.                  IF ColorDisplay THEN
  746.                      VideoSeg& = &HB800: CursorTop = 6: CursorBottom = 7
  747.                  ELSE
  748.                      VideoSeg& = &HB000: CursorTop = 14: CursorBottom = 15
  749.                  END IF
  750.  
  751.  InitPrt$, GraphicsChrSetOn$, GraphicsChrSetOff$, BoldPrtOn$, BoldPrtOff$,
  752.  ItalicPrtOn$, ItalicPrtOff$, RegPrt$, FastPrt$, WidePrt$, WidePrtOff$,
  753.  BigPrtOn$, BigPrtOff$, LQPrt$, DraftPrt$, MicroPrtOn$, MicroPrtOff$,
  754.  ElitePrt$, PicaPrt$, ReverseLF$  ... are printer control strings (you guessed
  755.  that!). Not all are set for every printer type, and I'm sure they're not all
  756.  perfect since I haven't systematically tested them all.
  757.  
  758. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  759.  
  760.                 ABOUT THE POWER-BASIC - QEDIT INTERFACE
  761.  
  762. My new source-code file editor is QEdit -- it's fast, infinitely customizable,
  763. it loads multiple files from the command line and swaps them or windows them,
  764. it can swap itself out to disk or EMS when you shell out to do something else
  765. so little RAM is tied up (that's all the task-switching I even need!) -- it's
  766. shareware and the registered version has workalike emulations for the major
  767. word processing packages. If you start QEdit with a command-line switch of
  768. /G1234 it jumps right to line 1234 of your file. So, perfect -- I can write
  769. batch files on the fly to handle both runtime errors and compiler errors.
  770. PQ.BAT and ERFIND.EXE do just that. They are documented within the source
  771. code.
  772.  
  773. Your main file should set GoToSourceFile = %True and say ON ERROR GOTO Oops;
  774. also set string values for SourceFile$ & SourceDir$.
  775.  
  776. The temporary batch files thus created are written to a RAMDisk. To allow both
  777. the batch file and the PB program to locate that drive I set a DOS environment
  778. variable, SET RD=D or SET RD=E or whatever.
  779.  
  780. I include a file, 2ERRORS.BAS, containing both a compile error and a runtime
  781. error. After you download QEdit, just type PQ 2ERRORS. QEdit will open the
  782. .BAS file. Don't fix it now, just exit and see what happens.
  783.  
  784. Oh yes, I almost forgot: these files call ERROR.EXE also. Download it from the
  785. Power Basic Forum libraries. Rodney Jones wrote it  -- very helpful, with no
  786. hoopla at all. It displays the explanation of any runtime error in Power Basic.
  787.  
  788. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  789.  
  790.            POWER BASIC PROGRAMMERS: IF YOU LIKE IT, PASS IT ON.
  791.  
  792.           Your feedback is welcomed -- write to 2097 7th St. in
  793.            Oakland, Ca. 94607 --  or via the CompuServe PCVENB
  794.                        Forum (# 71121,776)
  795.  
  796.                                                            -- Howard Ballinger
  797.